<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<script src="${pageContext.request.contextPath }/scripts/boot.js"
	type="text/javascript"></script>


<style type="text/css">
html,body {
	font-size: 12px;
	padding: 0;
	margin: 0;
	border: 0;
	height: 100%;
	overflow: hidden;
}
.col{
	color:red;
}
table tr{
	line-height:3;
}
	.asLabel .mini-textbox-border,
    .asLabel .mini-textbox-input,
    .asLabel .mini-buttonedit-border,
    .asLabel .mini-buttonedit-input,
    .asLabel .mini-textboxlist-border
    {
        border:0;background:none;cursor:default;
    }
    .asLabel .mini-buttonedit-button,
    .asLabel .mini-textboxlist-close
    {
        display:none;
    }
    .asLabel .mini-textboxlist-item
    {
        padding-right:8px;
    }  


.asLabel .mini-textbox-input{
	
	border:0;background:none;cursor:default;
	
}
</style>
</head>
<body>

	<fieldset style="border:solid 1px #aaa;padding:3px;">
		<legend>部队基本信息登记</legend>
		<form id="form1" method="post">

			<div style="padding-left:11px;padding-bottom:5px;">
				<table style="table-layout:fixed;width:700px;" >


					<tr>
						<td style="width:20%;text-align:right;"><span class="col">*</span>单位类型：</td>
						<td style="width:25%;text-align:left;"><input name="aab019"  style="width:80%"
							class="mini-textbox asLabel" value="部队"  /></td>
						
					</tr>
					<tr>
						
						<td style="width:20%;text-align:right;"><span class="col">*</span>单位名称：</td>
						<td style="width:25%;text-align:left;"><input id="tid" name="aab004" style="width:80%"
							class="mini-textbox" onvalidation="checkName" required="true"
							vtype="maxLength:50" />
						</td>

						<td style="width:20%;text-align:right;"><span class="col">*</span>联系人姓名：</td>
						<td style="width:25%;text-align:left"><input name="aae004" style="width:80%"
							class="mini-textbox" required="true" vtype="maxLength:25" />
						</td>
					</tr>
					<tr>
						<td style="width:20%;text-align:right;"><span class="col">*</span>联系电话：</td>
						<td style="width:25%;text-align:left;"><input name="aae005" style="width:80%"
							class="mini-textbox" required="true" vtype="maxLength:25" />
						</td>
						<td style="width:20%;text-align:right;">批准成立文号：</td>
						<td style="width:25%;text-align:left;"><input name="aae051" style="width:80%"
							class="mini-textbox" vtype="maxLength:25" />
						</td>
					</tr>
					<tr>
						<td style="width:20%;text-align:right;">批准成立部门：</td>
						<td style="width:25%;text-align:left;"><input name="aae048" style="width:80%"
							class="mini-textbox" vtype="maxLength:25" />
						</td>
						<td style="width:20%;text-align:right;">批准成立日期：</td>
						<td style="width:25%;text-align:left"><input name="aae049" style="width:80%"
							class="mini-datepicker" ondrawdate="onDrawDate" />
						</td>
					</tr>



				</table>
			</div>
			

			<div style="text-align:center;margin:20px;padding:10px;">
				<a class="mini-button" iconCls="icon-ok" onclick="onOk"
					style="width:60px;margin-right:20px;">确定</a> 
				<a class="mini-button" iconCls="icon-remove"
					onclick="onCancel" style="width:60px;">重置</a>
			</div>
		</form>
	</fieldset>
	<script type="text/javascript">
        mini.parse();
        var form = new mini.Form("form1");
        var flag=true;
        mini.getbyName("aab019").setReadOnly(true);
        mini.getbyName("aab019").addCls("asLabel");	
        //日期校验
         function onDrawDate(e) {
            var date = e.date;
            var d = new Date();

            if (date.getTime() > d.getTime()) {
                e.allowSelect = false;
            }
        }
        
        function checkName(){
        var name=mini.getbyName("aab004").getValue().trim();
		
			$.ajax({
				url:"/zyk/AB01_ARMY.do?method=getname",
				
				dataType:'json',
				data:{name:name},
				success:function(result){
					if(result!=null){
					
					mini.alert("单位名称重复，请重新输入");	
						 flag=false;
					}else{
						flag=true;
					}
				}
				
			});
         
      
        
        }
        
        
        
        function SaveData() {
       
            var o = form.getData(); 
             
            form.validate();
            if (form.isValid() == false) return;
            var json = mini.encode([o]);
            $.ajax({
                url: "/zyk/AB01_ARMY.do?method=saveAB01",
				type: 'post',
                data: { data: json},
                cache: false,
                success: function(text){
                	
                	
                    CloseWindow("save");
                    mini.alert("部队信息登记成功！单位编号为："+text);
                    form.clear();
                    mini.getbyName("aab019").setValue("部队");
                    
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }
        
         
       

        function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {            
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        function onOk(e) {
      		
      		if(flag){
      			SaveData();
      		}else{
      			mini.alert("单位名称重复，请重新输入！");
      		}
      		 
      		
      		
      		
      		
         
           
        }
        function onCancel(e) {
            CloseWindow("cancel");
            form.clear();
             mini.getbyName("aab019").setValue("部队");
            
        }
        //表单联动查询时使用
        function onDeptChanged(e) {
            var deptCombo = mini.getbyName("dept_id");
            var positionCombo = mini.getbyName("position");
            var dept_id = deptCombo.getValue();

            positionCombo.load("../data/AjaxService.jsp?method=GetPositionsByDepartmenId&id=" + dept_id);
            positionCombo.setValue("");
        }



    </script>
</body>
</html>
